package cn.zyq.demo.system.enums;

import cn.zyq.demo.system.enums.core.ResponseCodeEnum;
import cn.zyq.demo.system.exception.BusinessException;

/**
 * 消息类型 消息类型，1系统消息，2评论消息，3点赞
 */
public enum MsgTypeEnum {
    SYS_MSG("系统消息", 1),
    REPLY_MSG("评论消息", 2),
    LIKE_MSG("点赞消息", 3),
    EXAMINE_MSG("审核消息", 4),
    ;
    private String key;
    private Integer value;

    private MsgTypeEnum(String key, Integer value) {
        this.key = key;
        this.value = value;
    }

    public static String getKeyByValue(Integer value) {
        for (MsgTypeEnum item : MsgTypeEnum.values()) {
            if (item.value.equals(value)) return item.key;
        }
        throw new BusinessException(ResponseCodeEnum.ERROR.ERROR, "无效的value值");
    }

    public Integer getValue() {
        return value;
    }

    public String getKey() {
        return key;
    }

}
